package com.dalin.framework.common.clazz;

import java.util.Date;
import java.util.List;

import com.dalin.framework.common.clazz.Method;
import com.dalin.framework.common.utils.DateUtils;
import com.dalin.framework.common.utils.StringUtils;
import com.dalin.framework.common.PropertyConst;

/*****************************************************************************
 * @content: 类的注释                                                        *
 * @author : 那建林                                                          *
 * @crtDate: 2009-10-03                                                     *
 * @version: 1.02                                                           *
 ****************************************************************************/
public class Note {
	public static String getClassNote() {
		StringBuffer buf = new StringBuffer();
		buf.append("/*****************************************************************************")
			.append(PropertyConst.LINE_SEPARATOR);
		buf.append(" * @content: 类信息                                                                                                                                                    *").append(PropertyConst.LINE_SEPARATOR);
		buf.append(" * @author : 那建林                                                                                                                                                    *").append(PropertyConst.LINE_SEPARATOR);
		buf.append(" * @crtDate: " + DateUtils.getYmdhisStr(DateUtils.getCurrentDate()) + "                                            *").append(PropertyConst.LINE_SEPARATOR);
		buf.append(" * @modDate: " + DateUtils.getYmdhisStr(DateUtils.getCurrentDate()) + "                                            *").append(PropertyConst.LINE_SEPARATOR);
		buf.append(" * @version: 1.00                                                           *").append(PropertyConst.LINE_SEPARATOR);
		buf.append(" ****************************************************************************/").append(PropertyConst.LINE_SEPARATOR);
		return buf.toString();
	}
	
	public static String getMethodNote(Method method) {
		StringBuffer buf = new StringBuffer();
		buf.append("    /*************************************************************************")
			.append(PropertyConst.LINE_SEPARATOR);
		buf.append("     * @content: 方法注释信息").append(PropertyConst.LINE_SEPARATOR);
		if (!StringUtils.isBlank(method.getArgList().toString())) {
			for (String name : method.getArgList().getNameArray()) {
				buf.append("     * @param  : ")
					.append(name).append(PropertyConst.LINE_SEPARATOR);
			}
		}
		buf.append("     * @return : ")
			.append(method.getRtnType()).append(PropertyConst.LINE_SEPARATOR);
		buf.append("     * @author : 那建林").append(PropertyConst.LINE_SEPARATOR);
		buf.append("     * @crtDate: " + DateUtils.getYmdhisStr(DateUtils.getCurrentDate())).append(PropertyConst.LINE_SEPARATOR);
		buf.append("     * @modDate: " + DateUtils.getYmdhisStr(DateUtils.getCurrentDate())).append(PropertyConst.LINE_SEPARATOR);
		buf.append("     */").append(PropertyConst.LINE_SEPARATOR);
		return buf.toString();
	}

	public static String getHibernateAnnotation(
			String dbColumnName, String javaType, int columnLength) {
		StringBuffer buf = new StringBuffer();
		if (PropertyConst.STRING_STR.equals(javaType)) {
			buf.append("@Column(name=\"")
					.append(dbColumnName).append("\"")
					.append(PropertyConst.RIGHT_PARENTHESIS);
		} else if (PropertyConst.DATE_STR.equals(javaType)) {
			buf.append("@Temporal(TemporalType.TIMESTAMP)")
				.append(PropertyConst.LINE_SEPARATOR).append(PropertyConst.TAB)
				.append("@Column(name=\"").append(dbColumnName)
				.append("\")");
		} else { // 数据型的
			buf.append("@Column(name=\"")
				.append(dbColumnName).append("\"")
				.append(PropertyConst.RIGHT_PARENTHESIS);
		}
		return buf.toString();
	}
}
